#coding:utf-8
from django.http import HttpResponse,HttpResponseRedirect
from django.shortcuts import render_to_response
from django.contrib.auth.models import User
from django.contrib import auth,messages
from django.views.decorators.cache import cache_page, never_cache
from models import *
from forms import *
from utils import *
from django.template.context import RequestContext
from django.db import models
@never_cache
def index(request):
    
    groups = Group.objects.all()
    act_users = UserProfile.objects.activity_users()[0:12]
    devices = Device.objects.filter(audit=1)[0:5]
    apps = App.objects.order_by('-last_update')[0:5]
    topics = Topic.objects.hot_topics()
    tags = Tag.objects.all()    
    
    #ms = messages.get_messages(request)
#    print "#"*30
#    g = Group()
#    g.name ="1313"
#    for name in g._meta.fields:
#        print name.name,getattr(g, name.name)

    return render_to_response('index.html', locals(),context_instance=RequestContext(request))
    

def error(request):
    error = request.POST.get("error")
    return render_to_response('error.html', locals())


def error_500(request):
    error = request.POST.get("error")
    return render_to_response('error.html', locals())

def error_404(request):
    error = request.POST.get("error")
    return render_to_response('404.html', locals())


